﻿var trunPageObj;//翻页组件对像
$(initPage);
function initPage() {
	//初始化翻页组件
    trunPageObj =  $(".pageNext").turnPage(12, exportList);
	
	$("#query").click(function() {
		//alert("step 1");
		$("#data_list").empty();
		trunPageObj.gotoPage(1);//搜索第一页
	});
	trunPageObj.gotoPage(1);//搜索第一页
}
function queryList() {
	var pageno=trunPageObj.getCurrentPageNo();//当前第几页
	var pagecount=trunPageObj.getPageCount();//一页多少条
	//alert($.trim($("#stockAccount").val()));
	//alert($.trim($("#stockCode").val()));
	$.post("m/stock_query/querySeStock", {
		pageNo: pageno,
		pageSize : pagecount,
		stockAccount:$.trim($("#stockAccount").val()),
        fundAccount:$.trim($("#fundAccount").val()),
		stockCode:$.trim($("#stockCode").val())
	}, function(data) {
		if ($.checkErrorMsg(data) ) {
			var fileList = "";
			if(data.seStockPage && data.seStockPage.dataList){
				var dataList = data.seStockPage.dataList;
				$(dataList).each(function(i) {
					//alert(dataList[i].secCode);
					fileList += "<tr class='table_td_font' bgColor='#ffffff' onclick='selectTR(this)'>";  
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap >" + (dataList[i].seatNo ? dataList[i].seatNo : "") + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap >" + (dataList[i].branchNo ? dataList[i].branchNo : "") + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap >" + (dataList[i].exchangeType ? dataList[i].exchangeType : "") + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap >" + (dataList[i].taCode ? dataList[i].taCode : "") + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap >" + (dataList[i].stockAccount ? dataList[i].stockAccount : "") + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap >" + (dataList[i].stockCode ? dataList[i].stockCode : "") + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap >" + (dataList[i].fundAccount ? dataList[i].fundAccount : "") + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap >" +  dataList[i].amount + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap >" + (dataList[i].srcTable ? dataList[i].srcTable : "") + "</td>";
					fileList += "<td align='center'  height='25px' class='queryList_linebg' nowrap >" + (dataList[i].busiDate ? dataList[i].busiDate : "") + "</td>";
					fileList += "</tr>";
				});
			}
			$("#data_list").html(fileList);
			trunPageObj.setPageData(data.seStockPage);
		} 
	}, "json");
}
//选中行
function selectTR(obj) {
	//修改背景色
	$(obj).attr("bgColor","#FAEBD7").siblings().attr("bgColor","#FFFFFF");
}
function exportList() {
	var obj = window.showModalDialog(BASE_PATH + "page/export_select.jsp","","dialogWidth:200px;dialogHeight:80px;help:no;center:yes;status:no");
	if (obj) {
		window.open(BASE_PATH +"m/stock_query/exportSeStock?stockAccount=" + $.trim($("#stockAccount").val()) + "&stockCode=" + $.trim($("#stockCode").val()) + "&fundAccount=" + $.trim($("#fundAccount").val()) + "&expType=" + obj);
	}
}
//下拉多选的onchange函数，此函数名不能改
function onchangeThisValue(thisName){
}
